home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 12.1 KB | 389 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: MovieSel.cpp
- // Release Version: $ 1.0d1 $
- //
- // Author: Lonnie Millett
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef MOVIESEL_H
- #include "MovieSel.h"
- #endif
-
- #ifndef MOVIEPAR_H
- #include "MoviePar.h"
- #endif
-
- #ifndef MOVIEFRA_H
- #include "MovieFra.h"
- #endif
-
- #ifndef MOVIEFAC_H
- #include "MovieFac.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWMEMMGR_H
- #include <FWMemMgr.h>
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _SHAPE_
- #include <Shape.h>
- #endif
-
- #ifndef _DRAGDROP_
- #include <DragDrop.h>
- #endif
-
- #ifndef _XMPSESSM_
- #include <XMPSessM.h>
- #endif
-
- #ifndef _STDPROPS_
- #include <StdProps.h>
- #endif
-
- #ifndef _STDTYPES_
- #include <StdTypes.h>
- #endif
-
- #ifndef _TRNSFORM_
- #include <Trnsform.h>
- #endif
-
- #ifndef _STORAGEU_
- #include <StorageU.h>
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _TRANSLAT_
- #include <Translat.h>
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__DRAG__)
- #include <Drag.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__MOVIES__)
- #include <Movies.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(mathRoutinesIncludes)
- #include <math routines.h>
- #endif
-
- #pragma segment MoviePart
-
- //==============================================================================
- // •• class CMovieSelection
- //==============================================================================
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::CMovieSelection
- //---------------------------------------------------------------------------------------
-
- CMovieSelection::CMovieSelection()
- {
- fMoviePart = NULL;
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::InitMovieSelection
- //---------------------------------------------------------------------------------------
-
- void CMovieSelection::InitMovieSelection(CMoviePart* moviePart)
- {
- InitSelection(moviePart, FALSE, FALSE);
-
- fMoviePart = moviePart;
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::~CMovieSelection
- //---------------------------------------------------------------------------------------
-
- CMovieSelection::~CMovieSelection()
- {
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::CloseSelection
- //---------------------------------------------------------------------------------------
-
- void CMovieSelection::CloseSelection()
- {
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->CloseSelection();
- iter.Next();
- }
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::DoClear
- //---------------------------------------------------------------------------------------
-
- FW_Boolean CMovieSelection::DoClear()
- {
- TimeValue currentTime, duration;
- ((CMovieFacet*)fMoviePart->GetActiveFacet())->GetCurrentSelection(¤tTime, &duration);
-
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->ClearSelection(currentTime, duration);
- iter.Next();
- }
- return FALSE;
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::SelectAll
- //---------------------------------------------------------------------------------------
-
- void CMovieSelection::SelectAll()
- {
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->SelectAll();
- iter.Next();
- }
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::IsEmpty
- //---------------------------------------------------------------------------------------
-
- FW_Boolean CMovieSelection::IsEmpty() const
- {
- return ((CMovieFacet*)fMoviePart->GetActiveFacet())->IsEmpty();
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::ExternalizeSelection
- //---------------------------------------------------------------------------------------
-
- void CMovieSelection::ExternalizeSelection(XMPStorageUnit* storageUnit, FW_CFrame* commandFrame, XMPCloneKind cloneKind)
- {
- FW_UNUSED(commandFrame);
- FW_UNUSED(cloneKind);
-
- CMovieFacet* movieFacet = (CMovieFacet*)fMoviePart->GetActiveFacet();
- if (movieFacet)
- {
- XMPTranslation *translate = GetPart()->GetSession()->GetTranslation();
- XMPType PICTType = translate->GetISOTypeFromPlatformType('PICT', kXMPPlatformDataType);
-
- // Our content type is the standard 'moov' type
- storageUnit->AddProperty(kXMPPropContents)->AddValue(fMoviePart->GetContentPropertyValueType());
- FW_PlatformHandle movieHandle = movieFacet->CopySelection();
- FW_CMemoryManager::LockSystemHandle(movieHandle);
- storageUnit->SetValue(FW_CMemoryManager::GetSystemHandleSize(movieHandle), (XMPValue)*movieHandle);
- FW_CMemoryManager::UnlockSystemHandle(movieHandle);
- FW_CMemoryManager::FreeSystemHandle(movieHandle);
-
- // Add a PICT standard type for parts that don't understand movies
- storageUnit->AddProperty(kXMPPropContents)->AddValue(PICTType);
- PicHandle pictHandle = ((CMovieFacet*)fMoviePart->GetActiveFacet())->GetMovieAsPict();
- FW_CMemoryManager::LockSystemHandle((FW_PlatformHandle)pictHandle);
- storageUnit->SetValue(FW_CMemoryManager::GetSystemHandleSize((FW_PlatformHandle)pictHandle), (XMPValue)*pictHandle);
- FW_CMemoryManager::UnlockSystemHandle((FW_PlatformHandle)pictHandle);
- ::KillPicture(pictHandle);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::InternalizeSelection
- //---------------------------------------------------------------------------------------
-
- FW_Boolean CMovieSelection::InternalizeSelection(XMPStorageUnit* storageUnit, XMPCloneKind cloneKind)
- {
- FW_UNUSED(cloneKind);
-
- FW_Boolean internalized = FALSE;
- FW_PlatformHandle movieHandle;
-
- XMPTranslation *translate = GetPart()->GetSession()->GetTranslation();
- XMPType typeHFS = translate->GetISOTypeFromPlatformType('hfs ', kXMPPlatformDataType);
- XMPType PICTType = translate->GetISOTypeFromPlatformType('PICT', kXMPPlatformDataType);
- XMPType TEXTType = translate->GetISOTypeFromPlatformType('TEXT', kXMPPlatformDataType);
- XMPType sndType = translate->GetISOTypeFromPlatformType('snd ', kXMPPlatformDataType);
-
- if (storageUnit->Exists(kXMPPropContents, fMoviePart->GetContentPropertyValueType(), 0))
- {
- storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, fMoviePart->GetContentPropertyValueType(), 0, kXMPPosUndefined);
-
- unsigned long movieSize = storageUnit->GetSize();
- movieHandle = FW_CMemoryManager::AllocateSystemHandle(movieSize);
- THROW_IF_NULL(movieHandle);
-
- FW_CMemoryManager::LockSystemHandle(movieHandle);
- storageUnit->GetValue(movieSize, (XMPValue)*movieHandle);
- FW_CMemoryManager::UnlockSystemHandle(movieHandle);
-
- Movie newMovie;
- FW_Boolean dataRefChanged;
- THROW_IF_ERROR(::NewMovieFromHandle(&newMovie, movieHandle, newMovieActive, &dataRefChanged));
-
- CMovieFacet* movieFacet = (CMovieFacet*)fMoviePart->GetActiveFacet();
- if (movieFacet->GetMovie())
- {
- TimeValue currentTime, duration;
- movieFacet->GetCurrentSelection(¤tTime, &duration);
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->PasteMovieToSelection(newMovie, currentTime, duration);
- iter.Next();
- }
- ::DisposeMovie(newMovie);
- }
- else
- {
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->SetNewMovie(newMovie);
- iter.Next();
- }
- }
-
- FW_CMemoryManager::FreeSystemHandle(movieHandle);
-
- internalized = TRUE;
- }
- else if (storageUnit->Exists(kXMPPropContents, typeHFS, 0))
- {
- storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, typeHFS, 0, kXMPPosUndefined);
-
- Movie newMovie;
- AliasHandle movieFileAlias = NULL;
-
- unsigned long fileSize = storageUnit->GetSize();
- HFSFlavor* fileData = (HFSFlavor*)FW_CMemoryManager::AllocateBlock(fileSize);
- storageUnit->GetValue(fileSize, (XMPValue)fileData);
-
- THROW_IF_ERROR(::NewAlias(NULL, (FSSpec*)&(fileData->fileSpec), &movieFileAlias));
- newMovie = fMoviePart->GetMovieFromAlias(movieFileAlias);
-
- FW_CMemoryManager::FreeBlock(fileData);
- FW_CMemoryManager::FreeSystemHandle((FW_PlatformHandle)movieFileAlias);
-
- CMovieFacet* movieFacet = (CMovieFacet*)fMoviePart->GetActiveFacet();
- if (movieFacet->GetMovie())
- {
- TimeValue currentTime, duration;
- movieFacet->GetCurrentSelection(¤tTime, &duration);
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->PasteMovieToSelection(newMovie, currentTime, duration);
- iter.Next();
- }
- ::DisposeMovie(newMovie);
- }
- else
- {
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->SetNewMovie(newMovie);
- iter.Next();
- }
- }
-
- internalized = TRUE;
- }
- else if (storageUnit->Exists(kXMPPropContents, PICTType, 0))
- {
- storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, PICTType, (XMPValueIndex)0, kXMPPosUndefined);
-
- unsigned long pictSize = storageUnit->GetSize();
- PicHandle pictHandle = (PicHandle)FW_CMemoryManager::AllocateSystemHandle(pictSize);
- THROW_IF_NULL(pictHandle);
-
- FW_CMemoryManager::LockSystemHandle((FW_PlatformHandle)pictHandle);
- storageUnit->GetValue(pictSize, (XMPValue)*pictHandle);
- FW_CMemoryManager::UnlockSystemHandle((FW_PlatformHandle)pictHandle);
-
- this->PasteOSTypeToMovies((FW_PlatformHandle)pictHandle, 'PICT');
-
- ::KillPicture(pictHandle);
-
- internalized = TRUE;
- }
- else if (storageUnit->Exists(kXMPPropContents, TEXTType, 0))
- {
- storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, TEXTType, (XMPValueIndex)0, kXMPPosUndefined);
-
- unsigned long textSize = storageUnit->GetSize();
- FW_PlatformHandle textHandle = FW_CMemoryManager::AllocateSystemHandle(textSize);
- THROW_IF_NULL(textHandle);
-
- FW_CMemoryManager::LockSystemHandle(textHandle);
- storageUnit->GetValue(textSize, (XMPValue)*textHandle);
- FW_CMemoryManager::UnlockSystemHandle(textHandle);
-
- this->PasteOSTypeToMovies(textHandle, 'TEXT');
-
- FW_CMemoryManager::FreeSystemHandle(textHandle);
-
- internalized = TRUE;
- }
- else if (storageUnit->Exists(kXMPPropContents, sndType, 0))
- {
- storageUnit->Focus(kXMPPropContents, kXMPPosUndefined, sndType, (XMPValueIndex)0, kXMPPosUndefined);
-
- unsigned long sndSize = storageUnit->GetSize();
- FW_PlatformHandle sndHandle = FW_CMemoryManager::AllocateSystemHandle(sndSize);
- THROW_IF_NULL(sndHandle);
-
- FW_CMemoryManager::LockSystemHandle(sndHandle);
- storageUnit->GetValue(sndSize, (XMPValue)*sndHandle);
- FW_CMemoryManager::UnlockSystemHandle(sndHandle);
-
- this->PasteOSTypeToMovies(sndHandle, 'snd ');
-
- FW_CMemoryManager::FreeSystemHandle(sndHandle);
-
- internalized = TRUE;
- }
-
- return internalized;
- }
-
- //---------------------------------------------------------------------------------------
- // • CMovieSelection::PasteOSTypeToMovies
- //---------------------------------------------------------------------------------------
-
- void CMovieSelection::PasteOSTypeToMovies(FW_PlatformHandle newHandle, OSType handleType)
- {
- TimeValue currentTime, duration;
- ((CMovieFacet*)fMoviePart->GetActiveFacet())->GetCurrentSelection(¤tTime, &duration);
-
- FW_CPartFrameIterator iter(fMoviePart, fMoviePart->GetDefaultPresentation());
- while (!iter.IsDone())
- {
- ((CMovieFrame*)iter.CurrentItem())->PasteHandleToSelection(newHandle, handleType, currentTime, duration);
- iter.Next();
- }
- }
-